import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:my_app/pages/plugin_demos/example_calendardatepicker2.dart';
import 'package:my_app/pages/plugin_demos/example_device_info_plus.dart';
import 'package:my_app/pages/plugin_demos/example_easyloading.dart';
import 'package:my_app/pages/plugin_demos/example_flutter_picker.dart';
import 'package:my_app/pages/plugin_demos/example_logger_and_widgetsize.dart';
import 'package:my_app/pages/plugin_demos/example_package_info_plus.dart';
import 'package:my_app/pages/plugin_demos/example_url_launch.dart';
import 'package:my_app/pages/plugin_demos/open_app_test.dart';
import 'package:my_app/pages/widget_demos/table_and_launch_url.dart';

/// 使用dart3.x的增强枚举来集中管理路由地址与页面
/// 
/// 便于使用Ctrl+鼠标左键查看对应页面
/// 
/// 如果有需要，也可增加name选项
enum PluginRouters {
  openApp('/open-app', OpenAppTestPage()),
  tableAndLaunchUrl('/table-with-launch-url', TableAndLaunchUrlPage()),
  flutterPicker('/example-flutter-picker', ExampleFlutterPicker()),
  calendardatepicker2('/example-calendardatepicker2', ExampleCalendardatepicker2Page()),
  easyloading('/example-easyloading', ExampleEasyloadingPage()),
  loggerAndWidgetsize('/example-logger-and-widgetsize', ExampleLoggerAndWidgetsizePage()),
  packageInfoPlus('/example-package-info-plus', ExamplePackageInfoPlusPage()),
  deviceInfoPlus('/example-device-info-plus', ExampleDeviceInfoPlusPage()),
  urlLauncher('/example-url-launcher', UrlLauncherPage()),
  ;

  const PluginRouters(this.path, this.page);

  final String path;
  final Widget page;
}

List<RouteBase> generatePluginRoutes(GlobalKey<NavigatorState> rootkey) {
  return PluginRouters.values.map<RouteBase>((e) {
    return GoRoute(
      path: e.path,
      parentNavigatorKey: rootkey,
      builder: (context, state) => e.page,
    );
  }).toList();
  // return <RouteBase> [
  //   GoRoute(
  //     path: PluginRouters.openApp.path,
  //     parentNavigatorKey: rootkey,
  //     builder: (context, state) => PluginRouters.openApp.page,
  //   ),
  //   GoRoute(
  //     path: PluginRouters.tableAndLaunchUrl.path,
  //     parentNavigatorKey: rootkey,
  //     builder: (context, state) => PluginRouters.tableAndLaunchUrl.page,
  //   ),
  //   GoRoute(
  //     path: PluginRouters.flutterPicker.path,
  //     parentNavigatorKey: rootkey,
  //     builder: (context, state) => PluginRouters.flutterPicker.page,
  //   ),
  //   GoRoute(
  //     path: PluginRouters.calendardatepicker2.path,
  //     parentNavigatorKey: rootkey,
  //     builder: (context, state) => PluginRouters.calendardatepicker2.page,
  //   ),
  //   GoRoute(
  //     path: PluginRouters.easyloading.path,
  //     parentNavigatorKey: rootkey,
  //     builder: (context, state) => PluginRouters.easyloading.page,
  //   ),
  //   GoRoute(
  //     path: PluginRouters.loggerAndWidgetsize.path,
  //     parentNavigatorKey: rootkey,
  //     builder: (context, state) => PluginRouters.loggerAndWidgetsize.page,
  //   ),
  //   GoRoute(
  //     path: PluginRouters.packageInfoPlus.path,
  //     parentNavigatorKey: rootkey,
  //     builder: (context, state) => PluginRouters.packageInfoPlus.page,
  //   ),
  //   GoRoute(
  //     path: PluginRouters.deviceInfoPlus.path,
  //     parentNavigatorKey: rootkey,
  //     builder: (context, state) => PluginRouters.deviceInfoPlus.page,
  //   ),
  //   GoRoute(
  //     path: PluginRouters.urlLauncher.path,
  //     parentNavigatorKey: rootkey,
  //     builder: (context, state) => PluginRouters.urlLauncher.page,
  //   ),
  // ];
}